package chapter02;

import java.util.Scanner;

public class shopping {
    public static void main(String[] args) {
        int shuben=12;
        int qianbi=1;
        int xiangpi=2;
        int kele=3;
        int lingshi=5;
        System.out.println("书本的价格位"+shuben+"元，您总共有20元");
        System.out.println("1.铅笔的价格为："+qianbi+"元");
        System.out.println("2.橡皮的价格为："+xiangpi+"元");
        System.out.println("3.可乐的价格为："+kele+"元");
        System.out.println("4.零食的价格为："+lingshi+"元");
        Scanner scl = new Scanner(System.in);
        System.out.println("请输入其他需要购买的序列号：");
        int id= scl.nextInt();
        switch(id){
            case 1:
                int qianbimoney=20-shuben;
                int qianbisum=qianbimoney/qianbi;
                int qianbisurplus=qianbimoney%qianbi;
                System.out.println("购买完书还可以购买铅笔"+qianbisum+"个，还剩"+qianbisurplus+"元");
                break;
            case 2:
                int xiangpimoney=20-shuben;
                int xiangpisum=xiangpimoney/xiangpi;
                int xiangpisurplus=xiangpimoney%xiangpi;
                System.out.println("购买完书还可以购买橡皮"+xiangpisum+"个，还剩"+xiangpisurplus+"元");
                break;
            case 3:
                int kelemoney=20-shuben;
                int kelesum=kelemoney/kele;
                int kelesurplus=kelemoney%kele;
                System.out.println("购买完书还可以购买可乐"+kelesum+"个，还剩"+kelesurplus+"元");
                break;
            case 4:
                int lingshimoney=20-shuben;
                int lingshisum=lingshimoney/lingshi;
                int lingshisurplus=lingshimoney%lingshi;
                System.out.println("购买完书还可以购买零食"+lingshisum+"个，还剩"+lingshisurplus+"元");
                break;
            default:
                System.out.println("您输入的有误。");
                break;
        }
    }
}
